package com.teachoa.enumtype;

public enum UserTypeEnum {
	
	ADMIN(0, "管理"),
	TEACHER(1, "教师"),
	STUDENT(2, "学生"),
	EXPERT(3, "专家");
	
	private int code;
	private String desc;
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	private UserTypeEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public static UserTypeEnum getEnumByCode(int code) {
		UserTypeEnum[] enums = UserTypeEnum.values();
		for(UserTypeEnum enumtype:enums) {
			if(enumtype.getCode()==code) {
				return enumtype;
			}
		}
		return null;
	}

}
